package com.hzjh.h5mall.model.forgot

import com.hzjh.base.ext.frame.JHBaseVM
import com.hzjh.base.http.toParams
import com.hzjh.base.http.toVersionParams
import com.hzjh.base.utils.other.ActivityStackManage
import com.hzjh.h5mall.http.MallApi
import com.hzjh.h5mall.ui.login.LoginActivity

class ForgotVM : JHBaseVM(){
    //获取验证码
    fun reqForgetEmailCaptcha(email:String) {
        makeCall {
            onRequest {
                MallApi.create().reqForgetEmailCaptcha(email.toParams())
            }

            onSuccess {

            }

        }
    }
    //重置密码
    fun reqResetPassword(email:String,captcha:String,password:String) {
        val params = HashMap<Any, Any>()
        params["email"] = email
        params["captcha"] = captcha
        params["newPassword"] = password
        params["passwordAgain"] = password
        makeCall {
            onRequest {
                MallApi.create().reqResetPassword(params.toVersionParams())
            }
            onSuccess {
                ActivityStackManage.toActivity(LoginActivity::class.java)
            }
        }
    }

    //助记词充值密码
    fun reqResetPasswordBySrp(srps:String,newPassword:String,passwordAgain:String) {
        val params = HashMap<Any, Any>()
        params["srps"] = srps
        params["newPassword"] = newPassword
        params["passwordAgain"] = passwordAgain
        makeCall {
            onRequest {
                MallApi.create().reqResetPasswordBySrp(params.toVersionParams())
            }
            onRealSuccess {
                ActivityStackManage.toActivity(LoginActivity::class.java)
            }
        }
    }

}